home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-15 | 11.9 KB | 416 lines | [TEXT/MPS ] |
- //
- // myFileSearchProc.r
- //
- // The example file search proc uses TYPE and CREATOR to determine
- // list of matching files on target volume, rather than searching on filename.
- // Your search procedure ( code segment ) can use any approach that you wish.
- // We have chosen a relatively simple method for sake of simplicity. Our search
- // procedure example does not exclude files in the trash or files in any
- // installer temp folders that might exist in the system folder of the
- // target volume.
- //
- // Extra 'vers' resources of ID # (3) and (4) have been added to the source
- // "TeachText" file contained within subfolder "Disk 1:" so that the "original"
- // and "replaced" copies of "TeachText" ( on target volume )
- // can be distinguished from each other.
- //
- // Search procedures can be used to select files to be replaced, or can
- // be used within the rule framework to add Easy Install or Custom Install
- // packages depending on whether or not a file exists on the target volume.
- // Search procedures can also be used within the rule framework to display
- // an error message, warning the user that installation cannot be performed
- // to the selected target volume because a certain file does not exist on
- // the target volume. This feature is especially useful when performing
- // upgrades of application or system software.
- //
- // IMPORTANT: With Installer 4.0.3 the only atoms that support the file
- // search procedure are file ( 'infa' ) and resource ( 'inra' ) atoms. The
- // FolderMerge ( 'infm' ) and ResMerge ( 'inrm' ) atoms are not supported.
- // Even if one of the unsupported atoms uses a target spec ( 'intf' ) that
- // includes a file search proc, the normal file search mechanism will be
- // used when processing the unsupported atom.
- //
- // There are four packages in this example script. Each package utilizes
- // a sample file search procedure that overrides the default search path
- // for Installer 4.x. Each package generates one custom install option
- // for each of the following example cases:
- //
- // 1) file atom - delete on install, copy on install
- //
- // This option first deletes all found copies of "TeachText" and "SimpleText"
- // ( as well as any other files with Type 'APPL' and Creator 'ttxt' )
- // from the target volume ( making backups to "InstallerTemp:" during
- // live-install ), then copies the "TeachText" application contained in the
- // subfolder "Disk 1:" to the target volume to replace all found copies
- // of "TeachText" and "SimpleText".
- //
- // 2) file atom - delete on install, but don't copy on install
- //
- // This option deletes all found copies of "TeachText" and "SimpleText"
- // ( as well as any other files with Type 'APPL' and Creator 'ttxt' )
- // from the target volume ( making backups to "InstallerTemp:" during
- // live-install ).
- //
- // 3) resource atom - delete on install, copy on install
- //
- // This option first deletes the resource 'vers' (3) from all found
- // copies of "TeachText" and "SimpleText" ( as well as any other files
- // with Type 'APPL' and Creator 'ttxt' ) on the target volume ( making
- // backups to "InstallerTemp:" during live-install ), then copies the
- // 'vers' (3) resource item from within the "TeachText" application
- // contained in the subfolder "Disk 1:" to each copy of "TeachText"
- // and "SimpleText" found on the target volume.
- //
- // 4) resource atom - delete on install, but don't copy on install
- //
- // This option deletes the resource 'vers' (3) from all found
- // copies of "TeachText" and "SimpleText" on the target volume ( making
- // backups to "InstallerTemp:" during live-install ).
- //
- //
- //
- // mark young • 08/17/94
- //
- // Copyright 1993-1994, Apple Computer, Inc., All Rights Reserved
- //
-
- #include "InstallerTypes.r"
-
- // include the 'infn' code resource containing file searching procedure
- include "FindTargetFile.rsrc";
-
-
-
- // • framework and rules
-
- // custom install framework always uses ID# 766
-
- // Custom Install framework fires both rules listed below
- resource 'infr' ( kCustomInstallFrameworkRsrcID ) {
- format0 {{
- pickAll, { 100,500 },
- }}
- };
-
- // add the first four custom install packages
- resource 'inrl' ( 100 ) {
- format0 {{
- AddCustomItems {{ 100,200,300,400 }}
- }};
- };
-
- // reference 'insp' ( file search proc )
- // contained within 'intf' ( target file spec )
- resource 'inrl' ( 500 ) {
- format0 {{
- checkFileRsrcForkExists { 10001 }, // add the last package only if
- AddCustomItems {{ 500 }} // the rule above returned true
- }};
- };
-
-
- // • packages
-
- // package for file search proc
- // w/ file atoms - delete on install, copy on install
- resource 'inpk' (100) {
- format0 {
- showsOnCustom,
- removable,
- dontForceRestart,
- 0,
- 0,
- "Remove, then Replace all copies of “TeachText” on target volume.",
- {
- 'infa', 1000
- },
- }
- };
-
- // package for file search proc
- // w/ file atoms - delete on install, but don't copy on install
- resource 'inpk' (200) {
- format0 {
- showsOnCustom,
- removable,
- dontForceRestart,
- 0,
- 0,
- "Remove all copies of “TeachText” on target volume.",
- {
- 'infa', 2000
- },
- }
- };
-
-
- // package for file search proc
- // w/ resource atoms - delete on install, copy on install
- resource 'inpk' (300) {
- format0 {
- showsOnCustom,
- removable,
- dontForceRestart,
- 0,
- 0,
- "Add/Replace 'vers' (4) resource to all copies of “TeachText” on tgt vol.",
- {
- 'inra', 3000
- },
- }
- };
-
-
- // package for file search proc
- // w/ resource atoms - delete on install, but don't copy on install
- resource 'inpk' (400) {
- format0 {
- showsOnCustom,
- removable,
- dontForceRestart,
- 0,
- 0,
- "Remove 'vers' (4) resource from all copies of “TeachText” on tgt vol.",
- {
- 'inra', 4000
- },
- }
- };
-
- // this last package just provides an easy way to see if the
- // second rule in the Custom Install framework returned true.
-
- // package for file search proc
- // utilizes 'insp' from within installer rule framework
- resource 'inpk' (500) {
- format0 {
- showsOnCustom,
- notRemovable,
- dontForceRestart,
- 0,
- 0,
- "Rule calling 'insp' via 'intf' succeeded ( or I'd not be here ) !!",
- {
- 'infa', 1000
- },
- }
- };
-
- // • file atoms
-
- // file atom for file seach proc, remove and replace during install
- resource 'infa' (1000) {
- format1 {
- deleteWhenRemoving,
- deleteWhenInstalling,
- copy,
- dontIgnoreLockedFile,
- dontSetFileLocked,
- useVersProcToCompare,
- srcNeedExist,
- rsrcForkInRsrcFork,
- leaveAloneIfNewer,
- updateExisting,
- copyIfNewOrUpdate,
- rsrcFork,
- dataFork,
- 0,
- 0x0,
- 10001,
- {
- 10000,
- 0,
- 0
- },
- 0,
- 0,
- 0,
- "TeachText"
- }
- };
-
- // file atom for file seach proc, remove but don't copy during install
- resource 'infa' (2000) {
- format1 {
- deleteWhenRemoving,
- deleteWhenInstalling,
- dontCopy, // • don't Copy during Install
- dontIgnoreLockedFile,
- dontSetFileLocked,
- useVersProcToCompare, // Use version proc for compare
- srcNeedExist,
- rsrcForkInRsrcFork,
- leaveAloneIfNewer, // Do not update a newer file
- updateExisting, // Update an existing file
- copyIfNewOrUpdate,
- rsrcFork,
- dataFork,
- 0,
- 0x0,
- 10001,
- {
- 10000,
- 0,
- 0
- },
- 0,
- 0,
- 0,
- "TeachText"
- }
- };
-
- // • resource atoms
-
- // resource atom for file seach proc; remove, copy during install
- resource 'inra' (3000) {
- format1 {
- deleteWhenRemoving,
- deleteWhenInstalling,
- copy, // Copy during Install
- leaveAloneIfNewer, // Do not update a newer file
- tgtRequired, // Don't allow install unless target exists
- updateExisting, // Update an existing file
- copyIfNewOrUpdate, // Make or replace
- dontIgnoreProtection, // Respect those protected bits
- srcNeedExist, // Source must exist on install disk
-
- byID, // Reference resource by ID #
- nameNeedNotMatch, // Only use ID # for target of resource
-
- 0,
- 10001, // Target file spec
- 'vers', // Target resource type
- 4, // Target resource ID #
- 0x0, // Target resource attributes
- "resource search proc", // Target resource name
- {
- 10000, // Source file spec
- 'vers', // Source piece type
- 4, // Source piece ID #
- 0, // Target piece size
- "", // Source piece resource name
- },
- 0x0, // Source version #
- 0, // Version compare resource number
- 0, // Atom extender resource ID
- "" // Total target size
- }
- };
-
-
- // resource atom for file seach proc; remove, but don't copy during install
- resource 'inra' (4000) {
- format1 {
- deleteWhenRemoving,
- deleteWhenInstalling,
- dontCopy, // Don't copy during Install
- leaveAloneIfNewer, // Do not update a newer file
- tgtRequired, // Don't allow install unless target exists
- updateExisting, // Update an existing file
- copyIfNewOrUpdate, // Make or replace
- dontIgnoreProtection, // Respect those protected bits
- srcNeedExist, // Source must exist on install disk
- byID, // Reference resource by ID #
- nameNeedNotMatch, // Existing resource referenced by ID #
- // must have same name to be replaced.
- 0,
- 10001, // Target file spec
- 'vers', // Target resource type
- 4, // Target resource ID #
- 0x0, // Target resource attributes
- "resource search proc", // Target resource name
- {
- 10000, // Source file spec
- 'vers', // Source piece type
- 4, // Source piece ID #
- 0, // Target piece size
- "", // Source piece resource name
- },
- 0x0, // Source version #
- 0, // Version compare resource number
- 0, // Atom extender resource ID
- "" // Total target size
- }
- };
-
-
- // • file specs
-
- // target file spec for file search atom
- resource 'intf' (10001) {
- format1 {
- searchForFile, // • override default search path
-
- TypeCrMustMatch, // If this is set to TypeCrMustMatch
- // then a file with a different type
- // and creator than those specified
- // below will not be replaced.
- // If this is set to TypeCrNeedNotMatch
- // then type and creator of an existing
- // target file are ignored.
-
- // The Type and Creator fields will be used to set the
- // file's Type and Creator when a new file is created.
- 'APPL', // TYPE for new file
- 'ttxt', // CREATOR for new file
-
- 0, // finder attribute flags
- // filled by ScriptCheck is value is 0
-
- 1, // creation date for new file
- 1, // modification date for new file
- // NOTE: DATE values are filled
- // by ScriptCheck if the value is 1
-
- 200, // • 'insp' resource ID ( file search proc )
-
- ":TeachText" // path to target file
- }
- };
-
- // source file spec for file search atom
- resource 'infs' (10000) {
- 'APPL', // TYPE for source file
- 'ttxt', // CREATOR for source file
- 0x1, // creation DATE for source file
- searchForFile, // IGNORED in Installer 4.0.x
- TypeCrMustMatch, // TYPE, CREATOR must match file on install disk
- "Disk 1:TeachText" // PATH to source file
- };
-
-
- // • interface to search proc
-
- // file search proc
- resource 'insp' (200) {
- format0 {
- 'infn', // SEARCH PROC • Code Rsrc Type
- 20, // SEARCH PROC • Code Rsrc ID
- // NOTE: The code resource type and ID
- // values are specified within the makefile
- // for the search proc code resource.
- // In this example the lines that create the
- // search proc code resource are in the same
- // makefile as the one that builds the installer
- // script. You should use the values specified
- // in the makefile to fill in these fields.
-
- 0, // SEARCH PROC • RefCon
- // NOTE: This value will be passed
- // into your search proc code resource
- // when the search procedure is called.
-
- 0, // SEARCH PROC • Min Required Memory
- // NOTE: Set this value to 0 to use
- // the installer's allocate memory.
- // Unless your search proc code resource
- // has specific need for its own memory
- // heap you should always set this
- // value to 0.
-
- "Searching for all files."
- // SEARCH PROC • Description
- }
- };
-